package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.kaishengit.entity.Folder;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class FolderDao {
	
	private DBHelp<Folder> db = new DBHelp<Folder>();
	
	public void Save (String id,String name,String createtime,String t_employee_id,String t_project_id) {
		String sql = "insert into t_folder(id,name,createtime,t_employee_id,t_project_id) values(?,?,?,?,?)";
		db.executeSQL(sql, id,name,createtime,t_employee_id,t_project_id);
	}

	public List<Folder> FindAll () {
		String sql = "select id,name,createtime,t_employee_id,t_project_id from t_folder";
		return db.executeQueryForList(sql, new FolderRowMapper());
	}
	
	private class FolderRowMapper implements RowMapper<Folder> {
		
		public Folder mapperRow (ResultSet rs) throws SQLException {
			
			Folder folder = new Folder();
			folder.setId(rs.getString("id"));
			folder.setName(rs.getString("name"));
			folder.setCreatetime(rs.getString("createtime"));
			folder.setT_employee_id(rs.getString("t_employee_id"));
			folder.setT_project_id(rs.getString("t_project_id"));
			return folder;
		}
	}
}
